package com.ruoyi.web.controller.production.greenhousefilm;

import java.util.List;

import com.ruoyi.common.annotation.PropertyInject;
import com.ruoyi.common.enums.InjectType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.production.domain.greenhousefilm.GreenhousefilmAmount;
import com.ruoyi.production.service.greenhousefilm.IGreenhousefilmAmountService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 棚膜量Controller
 *
 * @author ruoyi
 * @date 2021-07-12
 */
@RestController
@RequestMapping("/production/greenhousefilmAmount")
public class GreenhousefilmAmountController extends BaseController
{
    @Autowired
    private IGreenhousefilmAmountService greenhousefilmAmountService;

    /**
     * 查询棚膜量列表
     */
    @PreAuthorize("@ss.hasPermi('production:greenhousefilmAmount:list')")
    @GetMapping("/list")
    public TableDataInfo list(GreenhousefilmAmount greenhousefilmAmount)
    {
        startPage();
        List<GreenhousefilmAmount> list = greenhousefilmAmountService.selectGreenhousefilmAmountList(greenhousefilmAmount);
        return getDataTable(list);
    }

    /**
     * 导出棚膜量列表
     */
    @PreAuthorize("@ss.hasPermi('production:greenhousefilmAmount:export')")
    @Log(title = "棚膜量", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(GreenhousefilmAmount greenhousefilmAmount)
    {
        List<GreenhousefilmAmount> list = greenhousefilmAmountService.selectGreenhousefilmAmountList(greenhousefilmAmount);
        ExcelUtil<GreenhousefilmAmount> util = new ExcelUtil<GreenhousefilmAmount>(GreenhousefilmAmount.class);
        return util.exportExcel(list, "棚膜量数据");
    }

    /**
     * 获取棚膜量详细信息
     */
    @PreAuthorize("@ss.hasPermi('production:greenhousefilmAmount:query')")
    @GetMapping(value = "/{greenhousefilmAmountId}")
    public AjaxResult getInfo(@PathVariable("greenhousefilmAmountId") Long greenhousefilmAmountId)
    {
        return AjaxResult.success(greenhousefilmAmountService.selectGreenhousefilmAmountById(greenhousefilmAmountId));
    }

    /**
     * 新增棚膜量
     */
    @PreAuthorize("@ss.hasPermi('production:greenhousefilmAmount:add')")
    @Log(title = "棚膜量", businessType = BusinessType.INSERT)
    @PostMapping
    @PropertyInject(type = InjectType.Insert)
    public AjaxResult add(@RequestBody GreenhousefilmAmount greenhousefilmAmount)
    {
        return toAjax(greenhousefilmAmountService.insertGreenhousefilmAmount(greenhousefilmAmount));
    }

    /**
     * 修改棚膜量
     */
    @PreAuthorize("@ss.hasPermi('production:greenhousefilmAmount:edit')")
    @Log(title = "棚膜量", businessType = BusinessType.UPDATE)
    @PutMapping
    @PropertyInject(type = InjectType.Update)
    public AjaxResult edit(@RequestBody GreenhousefilmAmount greenhousefilmAmount)
    {
        return toAjax(greenhousefilmAmountService.updateGreenhousefilmAmount(greenhousefilmAmount));
    }

    /**
     * 删除棚膜量
     */
    @PreAuthorize("@ss.hasPermi('production:greenhousefilmAmount:remove')")
    @Log(title = "棚膜量", businessType = BusinessType.DELETE)
	@DeleteMapping("/{greenhousefilmAmountIds}")
    public AjaxResult remove(@PathVariable Long[] greenhousefilmAmountIds)
    {
        return toAjax(greenhousefilmAmountService.deleteGreenhousefilmAmountByIds(greenhousefilmAmountIds));
    }
}
